﻿namespace SBlogCore.Common.Models
{
    /// <summary>
    /// 通用分页信息类
    /// </summary>
    [SkipScan]
    public class PageList<T>
    {
        public PageList()
        {

        }
        public PageList(int PageIndex,int TotalCount,int PageSize, IEnumerable<T> list)
        {
            this.PageIndex = PageIndex;
            this.TotalCount = TotalCount;
            this.PageSize = PageSize;
            this.Items = list;
        }
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 页容量
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总条数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);

        /// <summary>
        /// 当前页集合
        /// </summary>
        public IEnumerable<T> Items { get; set; }

        /// <summary>
        /// 是否有上一页
        /// </summary>
        public bool HasPrevPages { get; set; }

        /// <summary>
        /// 是否有下一页
        /// </summary>
        public bool HasNextPages { get; set; }
    }
}
